package com.min.kafka.serializer;

import com.min.kafka.entity.KMessage;
import com.min.kafka.util.GsonUtil;
import org.apache.kafka.common.serialization.Serializer;

import java.util.Map;

/**
 * kafka自定义序列化方法，采用gson
 * @author: fengt
 * @date: 2021/4/23 14:11
 **/
public class KMessageSerializer implements Serializer<KMessage> {

    @Override
    public void configure(Map<String, ?> map, boolean b) {

    }

    @Override
    public byte[] serialize(String s, KMessage kMessage) {
        return GsonUtil.toJson(kMessage).getBytes();
    }

    @Override
    public void close() {

    }
}